<%@ page contentType="text/html; charset=UTF-8"   %>
  <%@include file="../inc/public.inc" %> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>新增团体费用(expensesInfo/addTeamExpenses.jsp)</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath%>css/form.css" rel="stylesheet" type="text/css">
	<script language="javascript" type="text/javascript"
			src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
  </head>
  
  <body>
   <p>&nbsp;</p>
<table width="80%" align="center"  height="20" align=center border="0" cellspacing="0" cellpadding="0">
  			<tr bgcolor="#c0c0c0"> 
            	<td bgcolor="#c0c0c0" width="41%" height="4" align="left"> 
            		<font face=宋体 color=#000000><b>编辑费用</b></font>
            	</td>
            	<td height="19" width="59%"></td>
         	 </tr>
           <tr> 
            <td colspan="2" bgcolor="#000000" width="59%" height="1">
            	
            </td>
          </tr>
 </table>
<form action="ExpensesInfoServlet.servlet?opt=addTeamData" method="post" id="frm" name="frm">
<table width="80%" height="165" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#000000">
			<tr bgcolor="#FFFFFF"> 
            	<td class="s4" width="10%"><div align="center">所属团体<br></div></td>
    			<td colspan="3">　
					<select id="team" name="team" onchange="teamChang();">
						<option value=""  >----请选择----</option>
						<c:forEach items="${teamInfoList}" var="teamInfo">
							<option value="${teamInfo.id }"  >${teamInfo.teamName }</option>
						</c:forEach> 
                    </select>
                    
                     &nbsp;&nbsp; &nbsp;
                     <input  type="text"   value=""  onkeydown="serachTeam(this);"/>  （模糊过滤团体）
    			</td>
          
    			
    			
    			
 			 </tr>
  			<tr bgcolor="#FFFFFF"> 
            	<td class="s4" width="10%"><div align="center">费用日期<br></div></td>
    			<td>
                &nbsp;&nbsp; &nbsp;
    			<input id="generatedDate" readonly="readonly" name="generatedDate" class="Wdate" type="text" value="" 
    			onFocus="WdatePicker()"/> 　 
    			</td>
    			<td class="s4" width="10%"><div align="center">分类<br></div></td>
    			<td>
    			 	 <input id="classifyName" name="classifyName" type="text"   value=""/> 
    			</td>
    			 
 			 </tr>
             <tr bgcolor="#FFFFFF"> 
            	 
    			<td class="s4" width="10%"  ><div align="center">备注<br></div></td>
    			<td colspan="3">　
					<input id="discription" name="discription" type="text" size="80" value=""/> 
    			</td>
 			 </tr>
   			  <tr bgcolor="#FFFFFF"> 
    			<td class="s4" width="10%"><div align="center">参与人与付出费用金额<br></div></td>
    			<td colspan="3">　
    				<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#000000" id="feeTable">
    				 		<!-- 
    						<tr bgcolor="#FFFFFF">
    							<td  width="20%">
    								<input id="cyr_1" name="cyr" type="checkbox" checked="checked" value=""/> 
    								张三
    							</td>
    							<td  class="s4" width="20%" align="center">费用金额</td>
    							<td  width="30%">
    								<input type="text" name="je_1" value="50"   > 元（人民币）
    							</td>	
    						</tr>
    					  -->
					</table> 
    			</td> 
 			 </tr>

  			<tr bgcolor="#FFFFFF"> 
    			<td colspan="4" class="s4"> 
           			<div align="center"><font color="#FFFFFF"> 
             						<input type="button" name="Submit" value="保存" class="btnblue"  onclick="SaveSubmit();"/>
									&nbsp;
									<input type="reset" name="reset" value="重写" class="btnblue" />
									&nbsp;
									<input type="button" name="back" value="返回" class="btnblue" onclick="history.back(-1);"/>
             		 </font></div> 
         		</td>
  		</tr>
		</table>
</form>

</body>
</html>
<script type='text/javascript' src='<%=basePath%>dwr/engine.js'></script>
<script type='text/javascript' src='<%=basePath%>dwr/util.js'></script>
<script type='text/javascript' src='<%=basePath%>dwr/interface/GetTeamDwr.js'></script>
<script type="text/javascript">

		//搜索团体
		function serachTeam(obj,evt){
			var evt=window.event?window.event:evt;
            if (evt.keyCode==13){
               GetTeamDwr.teamListByName(obj.value,function(data){
               	 var teamObj=document.getElementById("team");
               	 teamObj.options.length=0;
               	 
               	  
               	 
               	 if(data!=null){
               	 	for(var i=0;i<data.length;i++){
               	 		var teamValue=data[i];
               	 		var option =new Option(teamValue.teamName,teamValue.id);
               	 		 
               	 		teamObj.add(option);
               	 	}
               	 }
               	  teamChang();
               	 
               	 
               });
            }
		}
		
		//团体选择改变
		function teamChang(){
				var teamObj=document.getElementById("team");
				
				var feeTable=document.getElementById("feeTable");
						for(var i=feeTable.rows.length-1; i>=0; i--){    
 							feeTable.deleteRow(i); 
						}
				
				if(teamObj.value!=""){
					GetTeamDwr.teamUserList(teamObj.value,function(data){
						
						
						if(data!=null){
							for(var i=0;i<data.length;i++){
		               	 		var userInfo=data[i];
		               	 		
		               	 		var row=feeTable.insertRow();
		               	 		row.style.backgroundColor="#FFFFFF";
		               	 		
		               	 		
		               	 		var cell1=row.insertCell(0);
		               	  		cell1.width="20%";
		               	 		 
		               	 		
		               	 		cell1.innerHTML="<input id=\"cyr_"+i+"\" name=\"cyr\" type=\"checkbox\"  checked=\"checked\"  onclick=\"changCheck("+i+");\" value=\""+userInfo.uid+"\"/> "+userInfo.name;
		               	 		
		               	 		var cell2=row.insertCell(1);
		               	 		cell2.width="20%";
		               	 		cell2.className="s4";
		               	 		cell2.align="center";
		               	 		
		               	 		 
		               	 		 
		               	 		cell2.innerHTML="费用金额";
		               	 		
		               	 		
		               	 		var cell3=row.insertCell(2);
		               	 		cell3.width="30%";
		               	 		 
		               	 		cell3.innerHTML="<input type=\"text\" id=\"je_"+i+"\" name=\"jeValue_"+userInfo.uid+"\" value=\"0\"   > 元（人民币）";
		               	 		 
		               	 		 
		               	 	}
						
						}
						
						
						
					});
				}
		
		}
		
		//改变是否选某人
		function changCheck(mid){
	 		var cry=document.getElementById("cyr_"+mid);
	 		var je=document.getElementById("je_"+mid);
	 		var flag = cry.checked;
	 		if(flag){
	 			je.disabled=false;
	 		}else{
	 			je.value=0;
	 			je.disabled=true;
	 		}
	 	}
		
		//保存提交
		function SaveSubmit(){
			var teamObj=document.getElementById("team");
			var generatedDateObj=document.getElementById("generatedDate");
			if(teamObj.value==""){
				//alert("请选择所属团体!");
				Ext.MessageBox.show({
		           title: '错误',
		           msg: '请选择所属团体!',
		           width: 250,
		           buttons: Ext.MessageBox.OK,
		           icon: Ext.MessageBox.ERROR
		            });
				return;
			}else if(generatedDateObj.value==""){
				 
				Ext.MessageBox.show({
		           title: '错误',
		           msg: '请输入费用日期!',
		           width: 250,
		           buttons: Ext.MessageBox.OK,
		           icon: Ext.MessageBox.ERROR
		            });
				return;
			}
		
			if(confirm('是否确定提交?')){
				document.all.frm.submit();
			}
		}
		
		
		</script>